
const { resolve,join } = require('path')
const { getProperty , setProperty } = require('../../lib/tools')
const { writeYaml } = require('../../lib/files')
module.exports = function({config:{entrys,globeConfig,dicts: {simpleTypes}},step1}){

    const entrysResult = {}
    const distDir = getProperty(globeConfig,g=>g.globe.dist.globe.step1,undefined)

    // 加载所有的类型处理函数
    const typesMap = {}
    for(let type in simpleTypes.types){
        typesMap[type] = require(resolve(__dirname,'../../',simpleTypes.src,simpleTypes.types[type]))
    }

    // 进行类型处理
    for(let entry in entrys){
        const {base,fields} = entrys[entry]
        const fieldResult = { fields: {} }
        fieldResult.base = typesMap.baseHandler(entrys[entry], globeConfig)
        fields.forEach((field)=>{
            const typeHandler = getProperty(field,f=>typesMap[f.type])
            if(typeHandler){
                setProperty(field,f=>fieldResult.fields[f.field] = typeHandler({base,field}))
            }
        })
        entrysResult[entry] = fieldResult
        step1[entry] = fieldResult
        
    }
    
    
}